package com.tanhua.manager.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tanhua.manager.service.QuestionSoulService;
import com.tanhua.pojo.QuestionSoul;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/question")
public class QuestionSoulController {

    @Autowired
    private QuestionSoulService questionService;

    @PostMapping
    public Boolean insertOne(@RequestBody QuestionSoul question){
       return questionService.insertOne(question);
    }

    @GetMapping("/{pageNum}/{pageSize}")
    public IPage<QuestionSoul> findByPage(@PathVariable("pageNum") Integer pageNum,@PathVariable("pageSize") Integer pageSize){
        System.out.println(questionService.findByPage(pageNum,pageSize).getRecords());
        return questionService.findByPage(pageNum,pageSize);
    }

    @PutMapping
    public Boolean update(@RequestBody QuestionSoul question){
        System.out.println(question);
        return questionService.updateById(question);
    }

    @DeleteMapping("/{questionId}")
    public Boolean delete(@PathVariable("questionId") Integer questionId){
        return questionService.removeById(questionId);
    }

    @DeleteMapping("/many/{num}")
    public Boolean deleteMany(@PathVariable("num") String num){

        return questionService.removeManyById(num);
    }
}
